package ch.rheintalconnection.sysventory.presentation;

import java.util.List;

import ch.rheintalconnection.sysventory.domain.Printer;

import com.vaadin.data.Item;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

public class PrinterWindow extends Window{

	private static final long serialVersionUID = 7319845246790771648L;

	public PrinterWindow(List<Printer> printers){
		this.setCaption("Drucker");
		this.setWidth("800px");
		this.setHeight("800px");
		
		Table table = new Table();
		table.setSizeFull();
		this.addComponent(table);
		
		
		table.addContainerProperty("Drucker", String.class, null);
		table.addContainerProperty("Treiber", String.class, null);
		table.addContainerProperty("Version", String.class, null);
		
		for (Printer printer : printers) {
			Object newItemId = table.addItem();
			Item row = table.getItem(newItemId);
			
			row.getItemProperty("Drucker").setValue(printer.getDescription());
			row.getItemProperty("Treiber").setValue(printer.getDriver());
			row.getItemProperty("Version").setValue(printer.getVersion());
		}
	}
}
